package com.jyszkj.map.util

import android.util.Log
import org.osmdroid.tileprovider.tilesource.FileBasedTileSource
import org.osmdroid.util.MapTileIndex

class OfflineTileSource(
    name: String,
    minZoom: Int,
    maxZoom: Int,
    tileSizePixels: Int,
    fileExtension: String
) : FileBasedTileSource(name, minZoom, maxZoom, tileSizePixels, fileExtension, arrayOf()) {

    // 重写此方法以匹配 /z/x/y/tile.png 结构
    override fun getTileRelativeFilenameString(pMapTileIndex: Long): String {
        val zoom = MapTileIndex.getZoom(pMapTileIndex)
        val x = MapTileIndex.getX(pMapTileIndex)
        val y = MapTileIndex.getY(pMapTileIndex)

        // 生成 /z/x/y/tile.png 格式的路径
        return "$zoom/$x/$y/tile$mImageFilenameEnding"
    }
}